home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
163_01
/
gets.c
< prev
next >
Wrap
Text File
|
1988-01-30
|
512b
|
24 lines
/*
** get a string from "stdin"
** terminate with \0
*/
extern int *stdin, fgetc();
gets(s) char *s; {
int n, ch;
char *str;
str=s; /* save original value */
n = 256;
while(--n) {
ch=fgetc(stdin);
if(ch<0) {
*s='\0';
return 0;
}
if(ch=='\n') break;
*s++=ch;
}
*s='\0';
return str;
}